package org.example.Controller;

import jakarta.annotation.Resource;
import org.example.common.Result;
import org.example.pojo.Cart;
import org.example.service.CartService;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("cart")
public class CartController {
    @Resource
    private CartService cartService;
    @PostMapping("/add")
    public Result addcart(@RequestBody Cart cart){
        Result result=cartService.add(cart);
        return result;
    }
    @PostMapping("/all")
    public Result getall(Integer userId,Integer businessId){
        Result result=cartService.getall(userId,businessId);
        return result;

    }
    @PostMapping("/update")
    public Result updatecart(@RequestBody Cart cart){
        Result result=cartService.updatecart(cart);
        return result;

    }
    @PostMapping("/clear")
    public Result clearcart(Integer userId,Integer businessId){
        Result result=cartService.clear(userId,businessId);
        return result;
    }
}
